//
//  ByViewIndexCancel.m
//  mijifen_ios
//
//  Created by mc on 2017/10/31.
//  Copyright © 2017年 itboye. All rights reserved.
//

#import "ByViewIndexCancel.h"

@implementation ByViewIndexCancel

- (instancetype)init{
    if (self = [super init]) {
        self.popMode = ZKBombPopModeTop;
        self.positionMode = ZKBombPositionModeCenter;
        self.damping = 0.6;
        self.aniDuration = 0.8;
        [self setupContents];

    }
    return self;
}

- (void)setupContents{
    UIView *bgView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH - 40, 200)];
    bgView.backgroundColor = [UIColor whiteColor];
    bgView.layer.cornerRadius = 4.0;
    // 提示 height:45
    UILabel *alertLabel = [[UILabel alloc] init];
    [bgView addSubview:alertLabel];
    [alertLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(bgView.mas_top);
        make.left.equalTo(bgView.mas_left);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 40, 45));
    }];
    alertLabel.text= @"提示";
    alertLabel.backgroundColor = BY_THEME_COLOR;
    alertLabel.textColor = BY_TEXT_COLOR;
    alertLabel.font = B_FONT(24);
    alertLabel.textAlignment = NSTextAlignmentCenter;
    
    
    
    // 确定 height:45
    UIButton *sureButton = [[UIButton alloc] init];
    [bgView addSubview:sureButton];
    [sureButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(bgView.mas_left);
        make.size.mas_equalTo(CGSizeMake((SCREEN_WIDTH - 40) / 2, 45));
        make.bottom.equalTo(bgView.mas_bottom);
    }];
    [sureButton setTitle:@"确定" forState:UIControlStateNormal];
    [sureButton setTitleColor:BY_TEXT_COLOR forState:UIControlStateNormal];
    sureButton.backgroundColor = BY_THEME_COLOR;
    sureButton.titleLabel.font = FONT(24);
    
    // 取消 height:45
    UIButton *cancelButton = [[UIButton alloc] init];
    [bgView addSubview:cancelButton];
    [cancelButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(sureButton.mas_right);
        make.size.mas_equalTo(CGSizeMake((SCREEN_WIDTH - 40) / 2, 45));
        make.bottom.equalTo(bgView.mas_bottom);
        
    }];
    [cancelButton setTitle:@"取消" forState:UIControlStateNormal];
    [cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    cancelButton.backgroundColor = [UIColor lightGrayColor];
    cancelButton.titleLabel.font = FONT(24);
    
    
   // 您确定注销吗？
    UILabel *alertInfoLabel = [[UILabel alloc] init];
    [bgView addSubview:alertInfoLabel];
    [alertInfoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(alertLabel.mas_bottom).offset((200 - 45 * 2 - 30) / 2);
        make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH - 40, 30));
        make.left.equalTo(bgView.mas_left);
    }];
    alertInfoLabel.textAlignment = NSTextAlignmentCenter;
    alertInfoLabel.font = FONT(20);
    alertInfoLabel.textColor = [UIColor redColor];
    alertInfoLabel.adjustsFontSizeToFitWidth = YES;
    alertInfoLabel.text = @"您确定要注销吗？";
    
    [cancelButton addTarget:self action:@selector(cancelAction) forControlEvents:UIControlEventTouchUpInside];
    [sureButton addTarget:self action:@selector(sureAction) forControlEvents:UIControlEventTouchUpInside];
    
    self.contentView = bgView;
}

- (void)sureAction{
    [ByCoreToolAlert showOnlyText:@"确定"];
    
}

- (void)cancelAction{
    [self remove];
}

@end
